# -*- coding:utf-8 -*-
"""
@文件 test.py
@Time : 2025/2/26
@Author: zjj
@Des: 测试数据
@Email: 1065377805@qq.com

"""
from fastapi import Depends, HTTPException
from fastapi.security import OAuth2PasswordRequestForm

from core.Auth import creat_token


def test():
    return 'test'

async def test_oath2(data: OAuth2PasswordRequestForm = Depends()):
    user_type = False
    if not data.scopes:
        raise HTTPException(401, "请选择作用域!")
    if "is_admin" in data.scopes:
        user_type = True
    jwt_data = {
        "user_id": data.client_id,
        "user_type": user_type
    }
    jwt_token = creat_token(data=jwt_data)

    return {"access_token": jwt_token, "token_type": "bearer"}
# def test_create_token(){
#
# }